﻿<%@ Page Title="" Language="C#" MasterPageFile="~/App_form/Menu/dao_tao.master" AutoEventWireup="true" CodeFile="htdt.aspx.cs" Inherits="App_form_Daotao_htdt" %>

<%@ Register TagPrefix="Control" TagName="menu_phai" Src="~/App_ctr/Admin/menu_phai.ascx" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">

    <div style="width: 100%">
        <div style="width: 20%; float: left;">
            <Control:menu_phai runat="server" ID="menuphai" />
        </div>
        <div style="width: 79.4%; float: right; border: 1px solid #d3d3d3;">
            <div style="background-image: url(../../CSS/images/ui-bg_glass_75_e6e6e6_1x400.png); font-weight: bold; height: 30px; border: 1px solid #d3d3d3; margin-top: 4px; text-align: center; padding-top: 8px; text-transform: uppercase;">
                Hình thức đào tạo
            </div>
            <div style="padding-left: 100px; width: inherit">
                <div style="width: 50%; float: left; padding-top: 150px;">
                    <div style="float: left; width: 20%;">
                        <label>
                            Tên  :
                        </label>
                    </div>
                    <div>
                        <Lib:textBox runat="server" ID="ten" Width="300px"></Lib:textBox>
                    </div>
                    <div style="width: 100%; height: 30px;"></div>
                    <div style="float: left; width: 100%; padding-left: 40px;">
                        <Lib:Button runat="server" ID="add" Text="Thêm mới" Width="100px" onClientClick="P_HT_DT_NH()"></Lib:Button>
                        <Lib:Button runat="server" ID="new" Text="Mới" Width="100px" onClientClick="P_HT_DT_MOI()"></Lib:Button>
                        <Lib:Button runat="server" ID="del" Text="Xóa" Width="100px" onClientClick="P_HT_DT_XOA()"></Lib:Button>
                    </div>
                    <div style="width: 100%; height: 10px;"></div>
                </div>
                <div style="width: 49%; float: left; padding-top: 5px;">
                    <Lib:gridView runat="server" ID="ht_dt" Width="300" Height="300" onClientCellClick="HT_DT_CELL_CLICK">
                        <Columns>
                            <Lib:Column BaseColumn="TEN" Name="Tên" Width="290" />
                        </Columns>
                        <Pager>
                            <Lib:Pager PageSize="10" />
                        </Pager>
                    </Lib:gridView>
                </div>
            </div>
        </div>
    </div>
    <asp:HiddenField ID="kthuoc" runat="server" Value="0,0" />
    <asp:HiddenField ID="id" runat="server" Value="0" />
    <script>

        //NHAP
        function P_HT_DT_NH() {
            try {
                var ma = $("#<%=id.ClientID%>").val(), ten = $("#<%=ten.ClientID%>").val();
                wdt_ma.FDT_HE_DT_NH(ma, ten, P_HT_DT_NH_KQ, ErrorDb, ErrorTimeOut);
                return false;
            }
            catch (e) {
                Msg.Show("Thông báo", e.message, "error");
            }
        }
        function P_HT_DT_NH_KQ(b_kq) {
            if (CheckError(b_kq)) {
                ShowError(b_kq);
                return;
            }
            var a_kq = b_kq.split("#");
            var grid = GetGridByID("<%=ht_dt.ClientID%>");
            var ma = a_kq[0];
            grid.dataBin(a_kq[1]);
            $("#<%=id.ClientID%>").val(ma);
            var b_hang = grid.getRowIndex(["ID"], [ma], ["=="]);
            if (b_hang >= 0)
                grid.setActiveRow(b_hang);
        }

        //MOI
        function P_HT_DT_MOI() {
            $("#<%=id.ClientID%>").val("");
            $("#<%=ten.ClientID%>").val("");
            var grid = GetGridByID("<%=ht_dt.ClientID%>");
            grid.resetActiveRow();
        }

        
        //XÓA
        function P_HT_DT_XOA() {
            try {
                var ma = $("#<%=id.ClientID%>").val();
                if (ma == "") {
                    Msg.Show(e.message);
                    return;
                }
                wdt_ma.FDT_HE_DT_XOA(ma, P_HT_DT_XOA_KQ, ErrorDb, ErrorTimeOut);
            }
            catch (e) {
                ShowError(e.message);
            }
        }
        function P_HT_DT_XOA_KQ(b_kq) {
            if (CheckError(b_kq)) {
                ShowError(b_kq);
                return;
            }
            var grid = GetGridByID("<%=ht_dt.ClientID%>");
            grid.dataBin(b_kq);
            var ma = $("#<%=id.ClientID%>").val()
            var b_hang = grid.getRowIndex(["ID"], [ma], ["<"]);
            if (b_hang >= 0)
                grid.setActiveRow(b_hang);
        }

        //ACTIVE
        function HT_DT_CELL_CLICK(row, cell, val) {
            try {
                var grid = GetGridByID("<%=ht_dt.ClientID%>");
                var aVal = grid.getValueActive(["ID", "TEN"]);
                if (aVal.MA == "")
                    return;
                $("#<%=id.ClientID%>").val(aVal.ID);
                $("#<%=ten.ClientID%>").val(aVal.TEN);
            }
            catch (e)
            { Msg.Show("Thông báo", e.message, "error"); }
        }

    </script>
</asp:Content>

